﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace MuXue.Zyiz.Template.OuterClient
{
    public static  class MsgApiClientServiceCollectionExtensions
    {
        public static IServiceCollection AddMsgApiClient(this IServiceCollection services, IConfiguration MsgClientConfiguration)
        {
            services.Configure<MsgClientConfiguration>(MsgClientConfiguration)
                    .AddHttpClient<IMsgApiClient, MsgApiClient>()
                    .ConfigureHttpClient(config=> {
                        config.BaseAddress = new Uri(MsgClientConfiguration.GetSection("url").Value);
                        config.Timeout = TimeSpan.FromSeconds(30);
                        });

            return services;
        }
    }
}
